///
/// @file CharType.cpp
/// @brief 字符类型实现
/// @author GitHub Copilot
/// @version 1.0
/// @date 2024-12-19
///
/// @copyright Copyright (c) 2024
///
/// @par 修改日志:
/// <table>
/// <tr><th>Date       <th>Version <th>Author  <th>Description
/// <tr><td>2024-12-19 <td>1.0     <td>GitHub Copilot  <td>新建
/// </table>
///
#include "CharType.h"

// 静态成员初始化
CharType * CharType::instance = nullptr;

CharType::CharType() : Type(CharTyID)
{}

CharType * CharType::getType()
{
    if (instance == nullptr) {
        instance = new CharType();
    }
    return instance;
}

std::string CharType::toString() const
{
    return "i8"; // LLVM IR中字符类型用i8表示
}

bool CharType::equals(const Type * other) const
{
    return other && other->isCharType();
}

int32_t CharType::getSize() const
{
    return 1; // 字符类型占1字节
}
